#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int y, m, d;
    scanf("%d%d%d", &y, &m, &d);
    if (m <= 2) {
        m += 12;
        y--;
    }
    int h = (d + 26 * (m + 1) / 10 + y % 100 + y % 100 / 4 + y / 100 / 4 + 5 * (y / 100)) % 7;
    switch (h) {
    case 0: printf("6"); break;
    case 1: printf("7");  break;
    case 2: printf("1");  break;
    case 3: printf("2");  break;
    case 4: printf("3");  break;
    case 5: printf("4");  break;
    case 6: printf("5");  break;
    }
    return 0;
}